import unittest
from unittest.mock import Mock
from discovery.mailbox_discoverer import MailboxDiscoverer

class TestDiscovery(unittest.TestCase):
    def setUp(self):
        mock_client = Mock()
        mock_client.paginate.return_value = [
            {"id": "u1", "displayName": "User1", "userPrincipalName": "user1@contoso.com"},
            {"id": "u2", "displayName": "User2", "userPrincipalName": "user2@contoso.com"}
        ]
        self.discoverer = MailboxDiscoverer(mock_client)
    
    def test_mailbox_discovery(self):
        result = self.discoverer.get_all_mailboxes()
        self.assertEqual(len(result), 2)
        self.assertEqual(result[0]["displayName"], "User1")
    
    def test_public_folder_scan(self):
        mock_client = Mock()
        mock_client.make_request.return_value = {
            "value": [{"name": "Public1"}, {"name": "Public2"}]
        }
        scanner = FolderScanner(mock_client)
        result = scanner.get_public_folder_tree()
        self.assertEqual(len(result["value"]), 2)